package com.shuai.feign;



import com.shuai.model.entity.InterfaceInfo;
import com.shuai.model.entity.User;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

/**
* @author 万文帅
* @description 针对表【interface_info(接口信息)】的数据库操作Service
* @createDate 2022-11-28 17:49:19
*/
@Component
@FeignClient("online-api-backend")
public interface InnerInterfaceFeign{

    /**
     * 从数据库查询接口是否存在
     */
    @GetMapping("/api/feign/getInterfaceInfo")
    InterfaceInfo getInterfaceInfo(@RequestParam("url") String url, @RequestParam("method") String method);

    /**
     * 数据库中查看已分配给用户的密钥
     * @param accessKey
     * @return
     */
    @GetMapping("/api/feign/getInvokeUser")
    User getInvokeUser(@RequestParam("accessKey") String accessKey);

    /**
     * 调用接口统计
     *
     * @param interfaceInfoId
     * @param userId
     * @return
     */
    @GetMapping("/api/feign/invokeCount")
    boolean invokeCount(@RequestParam("interfaceInfoId") long interfaceInfoId,@RequestParam("userId") long userId);

    /**
     * 判断剩余调用次数
     *
     * @param userId
     * @param interfaceInfoId
     * @return
     */
    @GetMapping("/api/feign/validLeftNum")
    boolean validLeftNum(@RequestParam("userId")Long userId,@RequestParam("interfaceInfoId") Long interfaceInfoId);

    @GetMapping("/api/feign/get")
    void get();

}
